import sys
from typing import List
import pytest

# 添加 hook 函数

def pytest_collection_modifyitems(
        session: "Session", config: "Config", items: List["Item"]
) -> None:
    # 对测试用例的路径和名字重新编码，编码后支撑中文
    for item in items:
        item.name = item.name.encode('utf-8').decode('unicode-escape')      # name 测试用例路径
        item._nodeid = item.nodeid.encode('utf-8').decode('unicode-escape') # _nodeid 是测试用例的名字

@pytest.hookimpl(hookwrapper=True)
def pytest_make_collect_report(collector):
    result = yield
    print("当前节点" +result.get_result().nodeid + ",采集结果："+result.get_result().outcome+ ",采集节点为："+str(result.get_result().result))
